
#include<stdio.h>
#include"header.h"
#include"file_index.h"
#include"double_cir_list.h"

void file_index()
{
    DIR * dir;
    struct dirent *ptr;
    dir = opendir("/home/songs/");
    while((ptr = readdir(dir)) != NULL) {
        if(strcmp(ptr->d_name, ".") == 0) {
            continue;
        }
        if(strcmp(ptr->d_name, "..") == 0) {
            continue;
        }
        insert(ptr->d_name);
    }
}
void file_mp4()
{
    DIR * dir;
    struct dirent *ptr;
    dir = opendir("/home/mp4/");
    while((ptr = readdir(dir)) != NULL) {
        if(strcmp(ptr->d_name, ".") == 0) {
            continue;
        }
        if(strcmp(ptr->d_name, "..") == 0) {
            continue;
        }
        insert(ptr->d_name);
    }
}


void random_list()
{
    int random;
    int n = 5;
    int i = 0;
    struct node *ptr = head->next;
    while(n != 0) {
        srand(n);
        random = rand() % 5;
        if(random == 0) {
            random++;
        }
        while(i != random) {
            ptr = ptr->next;
            if(ptr == head) {
                ptr = ptr->next;
            }
            i++;
        }
        i = 0;
        insert_random(ptr->name);
        n--;
    }
}


